﻿<?php
/**  
* PrinterDAO.php
*
*  단일 테이블에 적용 : SELECT * FROM `list_supplies` WHERE sSerial IN ('s00004', 's00259', 's01100') 형태로 쿼리
*   
* 
*/

require_once(CLASS_PATH."/__autoload.php");

class PrinterDAO extends Searchmgr
{
	protected function getQuery($keywords)
	{
		foreach($keywords as $str){
			if($this->isValid($str))
			{
				$keys[]  = " (hp.ppName LIKE '%$str%') ";  
			}
		}
	  
		if(isset($keys)) 
		{
		  $keys = array_unique($keys);      // 중복된 키워드 제거
		  $whereClause[] = join(' AND ', $keys); 
		}	
		
		$table 			= ' list_printer AS lp, haystack_printer AS hp ';		
		$whereClause 	=  join(' AND ', $whereClause);
		$whereClause   .=  " AND (lp.pSerial = hp.pSerial) ";
		$fields 		= 'lp.pSerial, lp.pType, lp.pMaker, lp.pName, lp.pComment, hp.psSerial ';
		$order  		= 'lp.pMaker, lp.pType DESC, lp.pName ';

		$qry = $this->db_select($table, $whereClause, $fields, $order);
		return $qry;  
	}
   
}
?>
